//
//  HXHelper.h
//  HYTest
//
//  Created by 刘林欣 on 16/7/24.
//  Copyright © 2016年 刘林欣. All rights reserved.
//

#import "EMSDKFull.h"

#define HXReqSuccessKey @"success"
#define HXReqInfoKey @"info"

@protocol HXHelperDelegate <NSObject>
/*!
 *  SDK连接服务器的状态变化时会接收到该回调
 *
 *  有以下几种情况，会引起该方法的调用：
 *  1. 登录成功后，手机无法上网时，会调用该回调
 *  2. 登录成功后，网络状态变化时，会调用该回调
 *
 *  @param aConnectionState 当前状态
 */
- (void)didConnectionStateChanged:(EMConnectionState)aConnectionState;
/*!
 *  当前登录账号在其它设备登录时会接收到该回调
 */
- (void)didLoginFromOtherDevice;
/*!
 *  当前登录账号已经被从服务器端删除时会收到该回调
 */
- (void)didRemovedFromServer;

@end


//异步调用，回调回来都是在主线程中
//所有对环信事件监听都需要经过此类
@interface HXHelper : NSObject <EMClientDelegate, EMGroupManagerDelegate, EMContactManagerDelegate, EMChatroomManagerDelegate, EMChatManagerDelegate>

+ (HXHelper*)getInstance;
- (void)addDelegate:(id<HXHelperDelegate>)delegate;
- (void)removeDelegate:(id<HXHelperDelegate>)delegate;
- (void)register:(NSString*)uname pwd:(NSString*)pwd cb:(void(^)(NSMutableDictionary* result))cb;
- (void)login:(NSString*)uname pwd:(NSString*)pwd cb:(void(^)(NSMutableDictionary* result))cb;

//应用进入后台
- (void)appDidEnterBg:(UIApplication *)application;
//应用激活
- (void)appWillEnterFg:(UIApplication *)application;


@end
